Ext.define('TS.view.base.UserPassWordEditor', {
    extend: 'Ext.window.Window',
    alias : 'widget.userpasswordeditor',

    title : '修改用户密码',
    layout: 'fit',
    autoShow: true,

    initComponent: function() {
        this.items = [
            {
                xtype: 'form',
                items: [
                    {
                        xtype: 'textfield',
                        name : 'oldPassWord',
                        fieldLabel: '原密码',
                        allowBlank: false,
                        inputType : 'password',
                        blankText : '原密码不能为空'
                    },
                    {
                        xtype: 'textfield',
                        name : 'password',
                        fieldLabel: '密码',
                        id:"edit-password",
                        inputType : 'password',
                        allowBlank: false,
                        blankText : '密码不能为空'
                    },
                    {
                        xtype: 'textfield',
                        name : 'confirmPassword',
                        fieldLabel: '密码确认',
                        inputType : 'password',
                        allowBlank: false,
                        blankText : '确认密码不能为空',
                        listeners: {
                        	blur : function(field){
                        		var p=this.up('form').items.items[0];
                        		var ptext=Ext.getCmp('edit-password').value;
					            if(field.value!=ptext)
					            {
					            	
					            	Ext.Msg.alert("提示","两次密码输入不同,请重新输入");	
					            	field.setValue('');
					            	field.focus(true);
					            }
					        }
                        }
                    }
                ]
            }
        ];
		
        this.buttons = [
            {
                text: '保存',
                action: 'save'
            },
            {
                text: '取消',
                scope: this,
                handler: this.close
            }
        ];
        this.callParent(arguments);
    },
    listeners : { 
		'show' : function() { 
			//this.down('form').items.items[3].store.load();
			this.down('form').items.items[0].focus(true,100); //第一个textfield获得焦点 
		} 
	}
});
